package com.hua.utility.encrypt;

import java.io.IOException;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public class EncryptionBase64 {

	/**
	 * BASE64加密(可逆加密)
	 * 
	 * BASE64 严格地说，属于编码格式，而非加密算法
	 * 
	 * @param key
	 * @return
	 * 
	 */
	public String encryptBASE64(byte[] key) {
		return (new BASE64Encoder()).encodeBuffer(key);
	}

	/**
	 * BASE64解密
	 * 
	 * @param key
	 * @return
	 * @throws IOException
	 * 
	 */
	public byte[] decryptBASE64(String key) throws IOException {
		return (new BASE64Decoder()).decodeBuffer(key);
	}

}